import { Request, Response } from 'express';

const roleList = [
  {
    code: 'super_admin',
    name: '超级管理员',
    description: '12',
  },
  {
    code: 'admin',
    name: '管理员',
    description: '123',
  },
  {
    code: 'hr_specialist',
    name: '人事专员',
    description: '1234',
  },
];
const query = {
  code: 'super_admin',
  name: '超级管理员',
  description: '',
  areaList: null,
  permissions: [
    'system',
    'system.role',
    'system.user',
    'system.role.create',
    'system.role.update',
    'system.role.delete',
    'system.role.page',
    'system.user.create',
    'system.user.update',
    'system.user.delete',
    'system.user.page',
  ],
  apiList: null,
};
const tree = [
  {
    name: 'system',
    displayName: '系统',
    parentName: '',
  },
  {
    name: 'person',
    displayName: '人事',
    parentName: '',
  },
  {
    name: 'access',
    displayName: '门禁',
    parentName: '',
  },
  {
    name: 'attend',
    displayName: '考勤',
    parentName: '',
  },
  {
    name: 'pos',
    displayName: '消费',
    parentName: '',
  },
  {
    name: 'park',
    displayName: '停车',
    parentName: '',
  },
  {
    name: 'visit',
    displayName: '访客',
    parentName: '',
  },
  {
    name: 'monitor',
    displayName: '视频',
    parentName: '',
  },
  {
    name: 'meeting',
    displayName: '会议',
    parentName: '',
  },
  {
    name: 'system.role',
    displayName: '角色管理',
    parentName: 'system',
  },
  {
    name: 'system.user',
    displayName: '用户管理',
    parentName: 'system',
  },
  {
    name: 'person.employee',
    displayName: '员工管理',
    parentName: 'person',
  },
  {
    name: 'person.biometric',
    displayName: '生物模板管理',
    parentName: 'person',
  },
  {
    name: 'person.organization',
    displayName: '部门管理',
    parentName: 'person',
  },
  {
    name: 'person.position',
    displayName: '职位管理',
    parentName: 'person',
  },
  {
    name: 'person.stranger',
    displayName: '离职人员管理',
    parentName: 'person',
  },
  {
    name: 'person.employee.create',
    displayName: '新增员工',
    parentName: 'person.employee',
  },
  {
    name: 'person.employee.update',
    displayName: '修改员工',
    parentName: 'person.employee',
  },
  {
    name: 'person.employee.delete',
    displayName: '删除员工',
    parentName: 'person.employee',
  },
  {
    name: 'person.employee.page',
    displayName: '查看员工',
    parentName: 'person.employee',
  },
  {
    name: 'person.organization.create',
    displayName: '新增部门',
    parentName: 'person.organization',
  },
  {
    name: 'person.organization.update',
    displayName: '修改部门',
    parentName: 'person.organization',
  },
  {
    name: 'person.organization.delete',
    displayName: '删除部门',
    parentName: 'person.organization',
  },
  {
    name: 'person.organization.page',
    displayName: '查看部门',
    parentName: 'person.organization',
  },
  {
    name: 'person.biometric.create',
    displayName: '新增生物模板',
    parentName: 'person.biometric',
  },
  {
    name: 'person.biometric.update',
    displayName: '修改生物模板',
    parentName: 'person.biometric',
  },
  {
    name: 'person.biometric.delete',
    displayName: '删除生物模板',
    parentName: 'person.biometric',
  },
  {
    name: 'person.biometric.page',
    displayName: '查看生物模板',
    parentName: 'person.biometric',
  },
  {
    name: 'person.position.create',
    displayName: '新增员工',
    parentName: 'person.position',
  },
  {
    name: 'person.position.update',
    displayName: '修改员工',
    parentName: 'person.position',
  },
  {
    name: 'person.position.delete',
    displayName: '删除员工',
    parentName: 'person.position',
  },
  {
    name: 'person.position.page',
    displayName: '查看员工',
    parentName: 'person.position',
  },
  {
    name: 'person.stranger.page',
    displayName: '查看离职人员',
    parentName: 'person.stranger',
  },
  {
    name: 'person.stranger.restore',
    displayName: '恢复离职人员',
    parentName: 'person.stranger',
  },
  {
    name: 'system.user.create',
    displayName: '新增用户',
    parentName: 'system.user',
  },
  {
    name: 'system.user.update',
    displayName: '修改用户',
    parentName: 'system.user',
  },
  {
    name: 'system.user.delete',
    displayName: '删除用户',
    parentName: 'system.user',
  },
  {
    name: 'system.user.page',
    displayName: '查看用户',
    parentName: 'system.user',
  },
  {
    name: 'system.role.create',
    displayName: '新增角色',
    parentName: 'system.role',
  },
  {
    name: 'system.role.update',
    displayName: '修改角色',
    parentName: 'system.role',
  },
  {
    name: 'system.role.delete',
    displayName: '删除角色',
    parentName: 'system.role',
  },
  {
    name: 'system.role.page',
    displayName: '查看角色',
    parentName: 'system.role',
  },
];

export default {
  // 'POST /system/role/page': (req: Request, res: Response) => {
  //   const { name } = req.body;
  //   res.send({
  //     success: true,
  //     result: {
  //       items: name ? roleList.filter((x) => x.name.includes(name)) : roleList,
  //       totalCount: 3,
  //     },
  //   });
  // },
  // 'POST /system/role/query': (req: Request, res: Response) => {
  //   const { code } = req.body;
  //   res.send({
  //     success: true,
  //     result: query,
  //   });
  // },
  // 'POST /system/role/create': (req: Request, res: Response) => {
  //   const { code } = req.body;
  //   res.send({
  //     success: true,
  //     result: null,
  //   });
  // },
  // 'POST /system/role/update': (req: Request, res: Response) => {
  //   const { code } = req.body;
  //   res.send({
  //     success: true,
  //     result: null,
  //   });
  // },
  // 'POST /system/role/delete': (req: Request, res: Response) => {
  //   const { code } = req.body;
  //   res.send({
  //     success: true,
  //     result: {
  //       RowsAffected: 0,
  //       Error: null,
  //     },
  //   });
  // },
  // 'POST /system/permission/list': (req: Request, res: Response) => {
  //   res.send({
  //     success: true,
  //     result: tree,
  //   });
  // },
  'POST /system/user/page': (req: Request, res: Response) => {
    res.send({
      success: true,
      result: {
        items: [
          {
            username: 'admin',
            nickname: '管理员用户',
            avatarUrl: 'admin',
            roleName: '管理员',
          },
          {
            username: 'root',
            nickname: '管理员用户',
            avatarUrl: 'root',
            roleName: '管理员',
          },
        ],
        totalCount: 2,
      },
    });
  },
  'POST /system/user/query': (req: Request, res: Response) => {
    res.send({
      success: true,
      result: {
        username: 'admin',
        nickname: '管理员用户',
        avatarUrl: '',
        roleCode: 'admin',
        roleName: '管理员',
        roleList: null,
      },
    });
  },
  'POST /system/user/create': (req: Request, res: Response) => {
    const { code } = req.body;
    res.send({
      success: true,
      result: null,
    });
  },
  'POST /system/user/update': (req: Request, res: Response) => {
    const { code } = req.body;
    res.send({
      success: true,
      result: null,
    });
  },
  'POST /system/user/delete': (req: Request, res: Response) => {
    const { code } = req.body;
    res.send({
      success: true,
      result: {
        RowsAffected: 0,
        Error: null,
      },
    });
  },
};
